<%@ page language="java" %>

<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
                 com.scalar.chiptrack.users.User,
                 com.scalar.chiptrack.commons.SessionKeys"%>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<html:html locale="true">

<HEAD>
	<TITLE>ScalarSoft - ChipTrac - Add Departments </TITLE>
    <META http-equiv='Content-Type' content='text/html; charset=windows-1252'>
    <LINK href='<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css' type='text/css' rel='stylesheet'>
	<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
    <script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
    <script language='javascript' >
    function refreshParentWindowListData()
    {
        var parentForm = window.opener.document.forms[0];//default
        var rowIndex = <%=request.getParameter("rowIndex")%>;

        var listCtrl;
        var listCtrl1;
        <logic:present name="refreshListData">

        listCtrl = parentForm['wipLotsList['+rowIndex+'].transferFrom'];
        listCtrl1 = parentForm['wipLotsList['+rowIndex+'].transferTo'];

        window.opener.deleteAllListOptions(listCtrl);
        window.opener.deleteAllListOptions(listCtrl1);
        window.opener.addOptionToList ( listCtrl, "Select From Dept" , "-1" );
        window.opener.addOptionToList ( listCtrl1, "Select To Dept" , "-1" );

        <logic:iterate id="departmentId" name="departmentList" type="org.apache.struts.util.LabelValueBean">
            window.opener.addOptionToList ( listCtrl,  '<bean:write name="departmentId" property="label"/>' , '<bean:write name="departmentId" property="value"/>' );
            window.opener.addOptionToList ( listCtrl1, '<bean:write name="departmentId" property="label"/>' , '<bean:write name="departmentId" property="value"/>' );
       </logic:iterate>
         
        </logic:present>
    }
    function save()
	{
        var pa =document.getElementById("errors");
        var pa1 =document.getElementById("messages");
	    pa.innerHTML = '';
        pa1.innerHTML = '';
        var form		            = document.transferMaterialform;

        if ( trim(form.departmentName.value) == '' || trim(form.departmentName.value).length == 0 )
        {
            pa.innerHTML = "<li>Please enter department name</li>";
            form.departmentName.focus();
            return;
        }
        else if ( trim(form.fullAccountNo.value) == '' || trim(form.fullAccountNo.value).length == 0 )
        {
            pa.innerHTML = "<li>Please enter fullAccount number</li>";
            form.fullAccountNo.focus();
            return;
        }
        var rowIndex = <%=request.getParameter("rowIndex")%>;
        document.transferMaterialform.action="<%=chipTracContext%>/transferMaterial.do?action=saveDepartment&rowIndex=" + rowIndex;
	    document.transferMaterialform.submit();
    }

    function closeWindow()
    {
        window.close();
    }
</script>
</HEAD>

<BODY bgcolor='ffffff' marginheight='0' marginwidth='0' topmargin='0' leftmargin='0' onload="refreshParentWindowListData()">
<%
    User user = ( User ) session.getAttribute ( SessionKeys.USER_KEY );
    if ( user != null )
    {
%>
    <html:form name="transferMaterialform" type="com.scalar.chiptrack.operations.dataentry.lotTransfer.forms.TransferMaterialForm" action="/transferMaterial.do">
    <table border="0" width="100%" align="center">
    <tr>
        <td colspan=4 align=right>
            <a href="javascript:closeWindow();" title='Click here to close this window' onMouseOver="window.status='Click here to close this window';return true"><font class='NArialL'><b>[Close this window]</b></font></a>
        </td>
    </tr>
    <tr><td colspan=4>&nbsp;</td></tr>
    <tr><td colspan=4 class="NArialW" align="center">Add Dapartment Names</td></tr>
    <tr><td colspan=4 class='NArialL'><strong><FONT id="errors" styleClass="NArialL" color='FF0000'/></strong></td></tr>
    <tr><td colspan=4 id="messages">
        <chiptrack:info styleClass="NArialL" />
        <chiptrack:errors styleClass="NArialL" />
        <chiptrack:messages type="info" styleClass="NArialL" />
        </td>
    </tr>

    <tr><td colspan="4"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>    
    <tr>
         <td colspan=1 class='NArialL' align="center" nowrap>Department Name:</td>
         <TD colspan=1 class='NArialL'><html:text property="departmentName" size="25" maxlength="50" styleClass="txfield" onkeypress="javascript:restrictSpecialChars()" name="transferMaterialform"/></TD>
         <td colspan=2>&nbsp;</td>
    </tr>
    <%--<tr><td colspan="4"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>--%>
    <tr>
         <td colspan=1 class='NArialL' align="center" nowrap>Full Account No:</td>
         <TD colspan=1 class='NArialL'><html:text property="fullAccountNo" size="25" maxlength="50" styleClass="txfield" onkeypress="javascript:restrictSpecialChars()" name="transferMaterialform"/></TD>
         <td colspan=2>&nbsp;</td>
    </tr>
    <%--<tr><td colspan="4"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>--%>
    <tr>
         <td colspan=1>&nbsp;</td>
         <td colspan=1 class='NArialL'><html:checkbox property="prodCategory" styleClass="txfield" name="transferMaterialform"/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Production Depatment</td>
         <td colspan=2>&nbsp;</td>
    </tr>

    <tr><td colspan="4"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
    <tr><td colspan="4" align=center><a href="javascript:save();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17" onmouseover="window.status='Click to Save Assembly Stage Name';return true" onmouseout="window.status='';return true" title="Click here to Save Assembly Stage Name"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <a href="javascript:document.transferMaterialform.reset()" onmouseover="window.status='Click to Reset';return true" onmouseout="window.status='';return true" title="Click here to Reset"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17"></a></td>
    </tr>
    <tr><td colspan="4" width="50%" align=center><a href="javascript:closeWindow();" title='Click here to close this window' onMouseOver="window.status='Click here to close this window';return true"><font class='NArialL'><b>[Close this window]</b></font></a></td></tr>

</TABLE>
</html:form>

<%
    }
    else
    {
%>
    <TABLE cellpadding='0' cellspacing='0' bgcolor='FDF5E6' border="0" width="100%"  height="100%" align=center>
        <TR>
            <TD>
                <TABLE align="center" border="0" width="40%" bgcolor="#FDF5E6">
                    <TR><TD>&nbsp;</TD></TR>
                    <TR><TD align="center" ><font class="NArialL" ><font color="red"><b>Session has been time out , Please close this window and login again.</b></font></font></TD></TR>
                    <TR><TD>&nbsp;</TD></TR>
                    <TR><TD align="center" ><a href="javascript:closeWindow();"><font class='NArialL'>[Close this window]</font></a></TD></TR>
                </TABLE>
            </TD>
       </TR>
       <TR><TD>&nbsp;</TD></TR>
    </TABLE>

<% } %>
</BODY>    
</html:html>
